package com.cyh.ebptpubjar.${table.packageName}.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cyh.ebptpubjar.${table.packageName}.entity.${table.entityNameWithEntity};
import com.cyh.ebptpubjar.${table.packageName}.dao.${table.daoName};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

/**
* ${table.controllerName}
* ${table.tableComment}
* @author  ${config.author}
* @version ${config.version}
* 描述：${config.description}
* 时间：${table.genDateTime?string("yyyy-MM-dd HH:mm:ss")}
*/

@Component
public class ${table.controllerName}{

    @Autowired
    private ${table.daoName} ${table.daoFirstLowerName};

    /**
    * 新增 ${table.tableComment}
    * @param entity
    * @return
    */
    public int insert(${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.insert(entity);
    }

    /**
    * 批量新增 ${table.tableComment}
    * @param entitys
    * @return
    */
    public int insertBatch(List<${table.entityNameWithEntity}> entitys){
        return ${table.daoFirstLowerName}.insertBatch(entitys);
    }

<#if table.primaryKeyIsNotEmpty==1>
    /**
    * 编辑(根据主键) ${table.tableComment}
    * @param entity
    * @return
    */
    public int updateByKey(${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.updateByKey(entity);
    }
</#if>
<#if table.primaryKeyIsNotEmpty==1>
    /**
    * 删除(根据主键) ${table.tableComment}
    * @param entity
    * @return
    */
    public int deleteByKey(${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.deleteByKey(entity);
    }
</#if>

    /**
    * 批量删除 ${table.tableComment}
    * @param entitys
    * @return
    */
    public int deleteBatchByCondition(List<${table.entityNameWithEntity}> entitys){
        return ${table.daoFirstLowerName}.deleteBatchByCondition(entitys);
    }
    /**
    * 删除(自定义) ${table.tableComment}
    * @param entity
    * @return
    */
    public int deleteByCondition(${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.deleteByCondition(entity);
    }
<#if table.primaryKeyIsNotEmpty==1>
    /**
    * 查询 ${table.tableComment}
    * @param entity
    * @return
    */
    public ${table.entityNameWithEntity} getByKey(${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.getByKey(entity);
    }
</#if>

    /**
    * 分页查询 ${table.tableComment}
    * @param page,entity
    * @return
    */
    public List<${table.entityNameWithEntity}> getByCondition(IPage<?> page, ${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.getByCondition(page,entity);
    }

    /**
    * 批量分页查询 ${table.tableComment}
    * @param page,entitys
    * @return
    */
    public List<${table.entityNameWithEntity}> getBatchByCondition(IPage<?> page, List<${table.entityNameWithEntity}> entitys){
        return ${table.daoFirstLowerName}.getBatchByCondition(page,entitys);
    }

    /**
    * 按照条件查询总数 ${table.tableComment}
    * @param entity
    * @return
    */
    public int selectCountByCondition(${table.entityNameWithEntity} entity){
        return ${table.daoFirstLowerName}.selectCountByCondition(entity);
    }
}